package com.gxa.logistics.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.gxa.logistics.common.base.PageWrapperDTO;
import com.gxa.logistics.common.base.RespResult;
import com.gxa.logistics.common.util.PageResultUtil;
import com.gxa.logistics.domain.dto.BillDTO;
import com.gxa.logistics.domain.entity.Bill;
import com.gxa.logistics.domain.vo.BillVO;
import com.gxa.logistics.mapper.BillMapper;
import com.gxa.logistics.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

@Service
@Transactional(rollbackFor = Throwable.class)
public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements BillService {

    @Autowired
    private BillMapper billMapper;


    @Override
    public RespResult<PageWrapperDTO<BillVO>>selectBill(BillDTO billDTO) {
       // return billMapper.selectBill(billDTO);
        PageHelper.startPage(billDTO.getPageNo(), billDTO.getPageSize());
        PageWrapperDTO<BillVO> pageWrapperDTO = new PageWrapperDTO<>();
        List<BillVO> billVOList =billMapper.selectBill(billDTO);
        PageResultUtil.setPageResult(billVOList, pageWrapperDTO);
        return RespResult.success(pageWrapperDTO);

    }

    @Override
    public List<String> selectAllOpType() {
        return billMapper.selectAllOpType();
    }
}
